import React, {memo} from "react";
import {Swipeable} from "react-native-gesture-handler";
import {Text, TouchableOpacity, View} from "react-native";

const handlePress = (item) => {
  console.log('Item pressed:', item);
  // 在这里可以处理列表项点击事件的逻辑
};
const handleDelete = (item) => {
  console.log('Delete item:', item);
  // 在这里可以处理删除操作的逻辑
};
const renderRightActions = (progress, dragX, item) => {
  const trans = dragX.interpolate({
    inputRange: [0, 50, 100],
    outputRange: [0, 0.2, 1],
  });
  return (
    <TouchableOpacity onPress={() => handleDelete(item)}>
      <View style={{ backgroundColor: 'red', justifyContent: 'center', alignItems: 'center', width: 100 }}>
        <Text style={{ color: 'white', paddingHorizontal: 10, paddingVertical: 15 }}>Delete</Text>
      </View>
    </TouchableOpacity>
  );
};
const RenderShortcut = memo(({ item }) => (
  <Swipeable renderRightActions={(progress, dragX) => renderRightActions(progress, dragX, item)}>
    <TouchableOpacity onPress={() => handlePress(item)} style={{ padding: 10, borderBottomWidth: 1, borderBottomColor: '#ccc' }}>
      <Text>{item.title}</Text>
    </TouchableOpacity>
  </Swipeable>
));

export default RenderShortcut;